/*!
\file Helper.h
\author Po
\brief Helper macro and draw mesh color function.
*/
#pragma once

#include <d3d9.h>
#include <d3dx9.h>

#ifndef DEFINE_HR
#define DEFINE_HR HRESULT hr
#endif

#ifndef HR_RETURN
#define HR_RETURN(x) { hr = x; if (FAILED(hr)) { return hr; } }
#endif

#ifndef HR_BREAK
#define HR_BREAK(x) { hr = x; if (FAILED(hr)) {break;} }
#endif

#ifndef SAFE_DELETE
#define SAFE_DELETE(x) { if ((x) != NULL) {delete (x); (x) = NULL;} }
#endif

#ifndef SAFE_RELEASE
#define SAFE_RELEASE(x) { if ((x) != NULL) {(x)->Release(); (x) = NULL; } }
#endif

/*! Replace *ppMesh with a mesh copy, set the new mesh with color(rgba). */
void DrawMeshColor(LPDIRECT3DDEVICE9 pd3dDevice,LPD3DXMESH *ppMesh, float fR, float fG, float fB, float fA);
